import { ref, onMounted } from 'vue'
import type { Ref } from 'vue'
import { messagexiaoxiApi } from "@/services/xiaoxi"

export const messageXtong=(pageNum=1):[Ref<Imessage.Xiaoxis[]>,Ref<number>,(page?:number)=>Promise<void>]=>{
    const data =ref<Imessage.xitongxiaoxi[]>([])
    const total= ref<Imessage.xitongxiaoxi['total']>(0) 


    const loadData= async (page=1)=>{
        let ret= await messagexiaoxiApi(page)
        if(ret.code===200){
            // console.log(ret.data.xitongxiaoxi);
            data.value=ret.data.xitongxiaoxi
            total.value=ret.data.total
        }
    }

    onMounted(()=>{
        loadData(pageNum)
    })

    return [data,total,loadData]
}